package com.ysd.lis.controller.sys;


import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.ysd.common.Result;
import com.ysd.common.dto.DeletesDto;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.dto.SysInterfaceMethodOutparamList;
import com.ysd.lis.entity.SysInterfaceMethodOutparam;
import com.ysd.lis.service.SysInterfaceMethodOutparamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 员工表
 * 前端控制器
 * </p>
 *
 * @author prs
 * @since 2024-04-25
 */
@Api(tags = "接口方法管理出参管理")
@RestController
@RequestMapping("/api/sys/sysInterfaceMethodOutParam")
public class SysInterfaceMethodOutParamController extends BaseController {

    @Autowired
    SysInterfaceMethodOutparamService sysInterfaceMethodOutParamService;


//    @ApiOperation("查询列表")
//    @GetMapping("/findInterfaceMethodOutParamList")
//    public Result findInterfaceMethodList(String methodId){
//        return Result.succ(sysInterfaceMethodOutParamService.getInterfaceMethodOutparamList(methodId)) ;
//    }

    @ApiOperation("查询接口字典出参列表")
    @GetMapping("/findInterfaceDictOutParamList")
    public Result findInterfaceDictOutParamList(String interfaceId,String methodId){
        Map map = new HashMap<>();
        map.put("dictList",sysInterfaceMethodOutParamService.getOutParamList(interfaceId));
        List<SysInterfaceMethodOutparam> interfaceMethodOutparamList = sysInterfaceMethodOutParamService.getInterfaceMethodOutparamList(methodId);
        if(CollectionUtils.isNotEmpty(interfaceMethodOutparamList)){
            map.put("methodList",interfaceMethodOutparamList);
            return Result.succ(map) ;
        }
        return Result.succ(map) ;
    }

    @ApiOperation("修改")
    @PostMapping("/saveOrUpdateInterfaceMethodOutParam")
    public Result saveOrUpdateInterfaceMethodOutParam(@RequestBody SysInterfaceMethodOutparamList sysInterfaceMethodOutparamList) {
        return Result.succ(sysInterfaceMethodOutParamService.updateInterfaceMethodOutparam(sysInterfaceMethodOutparamList));
    }

    @ApiOperation("批量删除")
    @PostMapping("/deleteBatchInterfaceMethodOutParam")
    public Result deleteBatchInterfaceMethod(@RequestBody DeletesDto dto){
        return  Result.succ(sysInterfaceMethodOutParamService.deleteInterfaceMethodOutparam(dto));
    }
}
